package com.example.kotlindemo.协程

import java.lang.reflect.Executable
import java.util.concurrent.Executor
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicInteger

object DefaultDispatch:Dispatcher {
    private val threadGroup =  ThreadGroup("")
    private val threadIndex = AtomicInteger(0)

    private val exxcutor = Executors.newFixedThreadPool(
        Runtime.getRuntime().availableProcessors()+1
    ){
        runnable ->
        Thread(threadGroup,runnable,"luge").apply {
            isDaemon = true
        }
    }



    override fun dispatch(block: () -> Unit) {
        exxcutor.submit(block)
    }
}